package com.zyw.mvc.support;

import com.alibaba.fastjson.serializer.PropertyFilter;
import org.springframework.util.ObjectUtils;

/**
 * @author zhangyw
 * @date 2017/3/7 14:37
 */
public class WrappedResultPropertyFilter implements PropertyFilter {
    @Override
    public boolean apply(Object object, String name, Object value) {

        if ("errMsg".equals(name)) {
            return !ObjectUtils.isEmpty(value);
        }

        if ("data".equals(name)) { // wrappedResult data == null 不参与序列化
            return value != null;
        }

        return true;
    }
}
